{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# EqualFrequencyDiscretiser\n",
    "\n",
    "The EqualFrequencyDiscretiser() divides continuous numerical variables\n",
    "into contiguous equal frequency intervals, that is, intervals that contain\n",
    "approximately the same proportion of observations.\n",
    "\n",
    "The interval limits are determined by the quantiles. The number of intervals,\n",
    "i.e., the number of quantiles in which the variable should be divided is\n",
    "determined by the user.\n",
    "\n",
    "**Note**\n",
    "\n",
    "For this demonstration, we use the Ames House Prices dataset produced by Professor Dean De Cock:\n",
    "\n",
    "Dean De Cock (2011) Ames, Iowa: Alternative to the Boston Housing\n",
    "Data as an End of Semester Regression Project, Journal of Statistics Education, Vol.19, No. 3\n",
    "\n",
    "http://jse.amstat.org/v19n3/decock.pdf\n",
    "\n",
    "https://www.tandfonline.com/doi/abs/10.1080/10691898.2011.11889627\n",
    "\n",
    "The version of the dataset used in this notebook can be obtained from [Kaggle](https://www.kaggle.com/c/house-prices-advanced-regression-techniques/data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "from feature_engine.discretisation import EqualFrequencyDiscretiser\n",
    "\n",
    "plt.rcParams[\"figure.figsize\"] = [15,5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Id</th>\n",
       "      <th>MSSubClass</th>\n",
       "      <th>MSZoning</th>\n",
       "      <th>LotFrontage</th>\n",
       "      <th>LotArea</th>\n",
       "      <th>Street</th>\n",
       "      <th>Alley</th>\n",
       "      <th>LotShape</th>\n",
       "      <th>LandContour</th>\n",
       "      <th>Utilities</th>\n",
       "      <th>...</th>\n",
       "      <th>PoolArea</th>\n",
       "      <th>PoolQC</th>\n",
       "      <th>Fence</th>\n",
       "      <th>MiscFeature</th>\n",
       "      <th>MiscVal</th>\n",
       "      <th>MoSold</th>\n",
       "      <th>YrSold</th>\n",
       "      <th>SaleType</th>\n",
       "      <th>SaleCondition</th>\n",
       "      <th>SalePrice</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>65.0</td>\n",
       "      <td>8450</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>208500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>20</td>\n",
       "      <td>RL</td>\n",
       "      <td>80.0</td>\n",
       "      <td>9600</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Reg</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2007</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>181500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>68.0</td>\n",
       "      <td>11250</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>223500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>70</td>\n",
       "      <td>RL</td>\n",
       "      <td>60.0</td>\n",
       "      <td>9550</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2006</td>\n",
       "      <td>WD</td>\n",
       "      <td>Abnorml</td>\n",
       "      <td>140000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>60</td>\n",
       "      <td>RL</td>\n",
       "      <td>84.0</td>\n",
       "      <td>14260</td>\n",
       "      <td>Pave</td>\n",
       "      <td>NaN</td>\n",
       "      <td>IR1</td>\n",
       "      <td>Lvl</td>\n",
       "      <td>AllPub</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "      <td>2008</td>\n",
       "      <td>WD</td>\n",
       "      <td>Normal</td>\n",
       "      <td>250000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 81 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   Id  MSSubClass MSZoning  LotFrontage  LotArea Street Alley LotShape  \\\n",
       "0   1          60       RL         65.0     8450   Pave   NaN      Reg   \n",
       "1   2          20       RL         80.0     9600   Pave   NaN      Reg   \n",
       "2   3          60       RL         68.0    11250   Pave   NaN      IR1   \n",
       "3   4          70       RL         60.0     9550   Pave   NaN      IR1   \n",
       "4   5          60       RL         84.0    14260   Pave   NaN      IR1   \n",
       "\n",
       "  LandContour Utilities  ... PoolArea PoolQC Fence MiscFeature MiscVal MoSold  \\\n",
       "0         Lvl    AllPub  ...        0    NaN   NaN         NaN       0      2   \n",
       "1         Lvl    AllPub  ...        0    NaN   NaN         NaN       0      5   \n",
       "2         Lvl    AllPub  ...        0    NaN   NaN         NaN       0      9   \n",
       "3         Lvl    AllPub  ...        0    NaN   NaN         NaN       0      2   \n",
       "4         Lvl    AllPub  ...        0    NaN   NaN         NaN       0     12   \n",
       "\n",
       "  YrSold  SaleType  SaleCondition  SalePrice  \n",
       "0   2008        WD         Normal     208500  \n",
       "1   2007        WD         Normal     181500  \n",
       "2   2008        WD         Normal     223500  \n",
       "3   2006        WD        Abnorml     140000  \n",
       "4   2008        WD         Normal     250000  \n",
       "\n",
       "[5 rows x 81 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv('housing.csv')\n",
    "\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "X_train : (1022, 79)\n",
      "X_test : (438, 79)\n"
     ]
    }
   ],
   "source": [
    "# let's separate into training and testing set\n",
    "X = data.drop([\"Id\", \"SalePrice\"], axis=1)\n",
    "y = data.SalePrice\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(\n",
    "    X, y, test_size=0.3, random_state=0)\n",
    "\n",
    "print(\"X_train :\", X_train.shape)\n",
    "print(\"X_test :\", X_test.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA2cAAAE/CAYAAADCCbvWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAepElEQVR4nO3df7Cld10f8PfHBBIkKIkh65KkbGhTK5gS6E6M0qG3BE0gjomOOLEBNpbOtiMi1nRgI46/pumktjrQUbQpoEv5EcMPJzsEq2nwjmPFRH6EH0mICbCQJUsWUIRlbOzCp3+cZ/WyuXfvPXfvj+fe+3rNnDnnfM/znPM9nz33Pve93+/zPdXdAQAAYH1903p3AAAAAOEMAABgFIQzAACAERDOAAAARkA4AwAAGAHhDAAAYASEM1hEVR2uqqeudz8AANjchDM2paq6qqruqKqvVtWh4fZPVFUtsP3vVNV/nO+x7j6tuz85xWtfU1VdVT+63P4DwEZSVfur6nlTbD9TVQcWeMxxlC1LOGPTqaprk7w2yX9J8u1JtiX5d0meneSx82x/0gp3YVeSvxyuj9fPk1f4dQFgM3AcZcsSzthUqupbk/xykp/o7nd091d64kPdfXV3PzKMkv1mVb2nqr6a5F8u8pxdVf+oqi6uqs/NDXNV9UNV9ZE595+S5F8k2Z3k0qraNuexmao6UFWvqqrPJfntqvqmqtpTVZ+oqi9W1c1Vdcacfd4+vOZfV9UfV9XTV6xYALCKquqUqnpNVT00XF4ztD0+ye8nefJw6sDhqnrysI/jK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4AAABGQDgDAAAYAeEMAABgBIQzAACAEfj/zbRLNhWNFzsAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 1080x360 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# we will use two continuous variables for transformation\n",
    "\n",
    "X_train[[\"LotArea\", 'GrLivArea']].hist(bins=50)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The EqualFrequencyDiscretiser() works only with numerical variables.\n",
    "A list of variables can be passed as argument. Alternatively, the discretiser\n",
    "will automatically select and transform all numerical variables.\n",
    "\n",
    "The EqualFrequencyDiscretiser() first finds the boundaries for the intervals or\n",
    "quantiles for each variable, fit.\n",
    "\n",
    "Then it transforms the variables, that is, it sorts the values into the intervals,\n",
    "transform.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "EqualFrequencyDiscretiser(q=10, return_boundaries=False, return_object=False,\n",
       "                          variables=['LotArea', 'GrLivArea'])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "Parameters\n",
    "----------\n",
    "\n",
    "q : int, default=10\n",
    "    Desired number of equal frequency intervals / bins. In other words the\n",
    "    number of quantiles in which the variables should be divided.\n",
    "\n",
    "variables : list\n",
    "    The list of numerical variables that will be discretised. If None, the\n",
    "    EqualFrequencyDiscretiser() will select all numerical variables.\n",
    "\n",
    "return_object : bool, default=False\n",
    "    Whether the numbers in the discrete variable should be returned as\n",
    "    numeric or as object. The decision is made by the user based on\n",
    "    whether they would like to proceed the engineering of the variable as\n",
    "    if it was numerical or categorical.\n",
    "\n",
    "return_boundaries: bool, default=False\n",
    "    whether the output should be the interval boundaries. If True, it returns\n",
    "    the interval boundaries. If False, it returns integers.\n",
    "'''\n",
    "\n",
    "efd = EqualFrequencyDiscretiser(q=10, variables=['LotArea', 'GrLivArea'])\n",
    "\n",
    "efd.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'LotArea': [-inf,\n",
       "  5007.1,\n",
       "  7164.6,\n",
       "  8165.700000000001,\n",
       "  8882.0,\n",
       "  9536.0,\n",
       "  10200.0,\n",
       "  11046.300000000001,\n",
       "  12166.400000000001,\n",
       "  14373.9,\n",
       "  inf],\n",
       " 'GrLivArea': [-inf,\n",
       "  912.0,\n",
       "  1069.6000000000001,\n",
       "  1211.3000000000002,\n",
       "  1344.0,\n",
       "  1479.0,\n",
       "  1603.2000000000003,\n",
       "  1716.0,\n",
       "  1893.0000000000005,\n",
       "  2166.3999999999996,\n",
       "  inf]}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# binner_dict contains the boundaries of the different bins\n",
    "efd.binner_dict_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_t = efd.transform(X_train)\n",
    "test_t = efd.transform(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([8, 3, 0, 4, 1, 2, 6, 9, 7, 5], dtype=int64)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# the numbers are the different bins into which the observations\n",
    "# were sorted\n",
    "train_t['GrLivArea'].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([4, 0, 2, 3, 1, 7, 5, 8, 6, 9], dtype=int64)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# the numbers are the different bins into which the observations\n",
    "# were sorted\n",
    "train_t['LotArea'].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>LotArea</th>\n",
       "      <th>GrLivArea</th>\n",
       "      <th>LotArea_binned</th>\n",
       "      <th>GrLivArea_binned</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>64</th>\n",
       "      <td>9375</td>\n",
       "      <td>2034</td>\n",
       "      <td>4</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>682</th>\n",
       "      <td>2887</td>\n",
       "      <td>1291</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>960</th>\n",
       "      <td>7207</td>\n",
       "      <td>858</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1384</th>\n",
       "      <td>9060</td>\n",
       "      <td>1258</td>\n",
       "      <td>4</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1100</th>\n",
       "      <td>8400</td>\n",
       "      <td>438</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      LotArea  GrLivArea  LotArea_binned  GrLivArea_binned\n",
       "64       9375       2034               4                 8\n",
       "682      2887       1291               0                 3\n",
       "960      7207        858               2                 0\n",
       "1384     9060       1258               4                 3\n",
       "1100     8400        438               3                 0"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# here I put side by side the original variable and the transformed variable\n",
    "tmp = pd.concat([X_train[[\"LotArea\", 'GrLivArea']], train_t[[\"LotArea\", 'GrLivArea']]], axis=1)\n",
    "tmp.columns = [\"LotArea\", 'GrLivArea',\"LotArea_binned\", 'GrLivArea_binned']\n",
    "tmp.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA3sAAAFKCAYAAACkdEbCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3de5hkZXXv8e8PBkEuoggi9/GCGIhKcIIXjBIVb6ioEQMqQUQxOR4xiRrwEtEYIzkx5phjopKoYBQQiQpGjoLo4NEIMiCKiAoiAoIwinJVEFznj71bira7p3q6q2vXnu/nefqpXfv2rqrq6TVr7/d9K1WFJEmSJKlf1ht3AJIkSZKkxWexJ0mSJEk9ZLEnSZIkST1ksSdJkiRJPWSxJ0mSJEk9ZLEnSZIkST1ksacll+TYJH87praT5ENJfpbka/M8dnmSSrJsVPGNQpIXJTl93HEspiQ3J3nguONYkyR7J7lq3HFImhzmyKVljhwfc+TSsNgTSS5Pcm2STQbWvSzJyjGGNSqPA/YBtq+qPccdzGKbKdlW1Uer6injjGuxVdWmVXXZMPu278eDRx2TpH4yR/aHOfK3mSP7z2JPU5YBrx53EPOVZP15HrITcHlV3TKKeBaqvarqv8vWuK8Qj7t9SZ1hjuwAc+TdjTtHjbt9Dcd/MJryD8Brk9x7+oaZroQlWZnkZe3yS5J8Jck/Jfl5ksuSPLZdf2WS65IcPO20WyY5I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qg6rqwnHEI0nSUkvySeAB01YfUVWfG0c8UhfYjVOSJEmSeshunJIkSZLUQxZ7kiRJktRDFnuSJEmS1EMWe5IkSZLUQxZ7kiRJktRD/x+hrq6GvM/0uQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1080x360 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# in  equal frequency discretisation, we obtain the same amount of observations\n",
    "# in each one of the bins.\n",
    "plt.subplot(1,2,1)\n",
    "tmp.groupby('GrLivArea_binned')['GrLivArea'].count().plot.bar()\n",
    "plt.ylabel('Number of houses')\n",
    "plt.title('Number of observations per interval')\n",
    "\n",
    "plt.subplot(1,2,2)\n",
    "tmp.groupby('LotArea_binned')['LotArea'].count().plot.bar()\n",
    "plt.ylabel('Number of houses')\n",
    "plt.title('Number of observations per interval')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Return interval limits instead"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "EqualFrequencyDiscretiser(q=10, return_boundaries=True, return_object=False,\n",
       "                          variables=['LotArea', 'GrLivArea'])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Now, let's return bin boundaries instead\n",
    "\n",
    "efd = EqualFrequencyDiscretiser(\n",
    "    q=10, variables=['LotArea', 'GrLivArea'], return_boundaries=True)\n",
    "\n",
    "efd.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_t = efd.transform(X_train)\n",
    "test_t = efd.transform(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([Interval(-inf, 912.0, closed='right'),\n",
       "       Interval(912.0, 1069.6, closed='right'),\n",
       "       Interval(1069.6, 1211.3, closed='right'),\n",
       "       Interval(1211.3, 1344.0, closed='right'),\n",
       "       Interval(1344.0, 1479.0, closed='right'),\n",
       "       Interval(1479.0, 1603.2, closed='right'),\n",
       "       Interval(1603.2, 1716.0, closed='right'),\n",
       "       Interval(1716.0, 1893.0, closed='right'),\n",
       "       Interval(1893.0, 2166.4, closed='right'),\n",
       "       Interval(2166.4, inf, closed='right')], dtype=object)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# the numbers are the different bins into which the observations\n",
    "# were sorted\n",
    "np.sort(np.ravel(train_t['GrLivArea'].unique()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([Interval(-inf, 912.0, closed='right'),\n",
       "       Interval(912.0, 1069.6, closed='right'),\n",
       "       Interval(1069.6, 1211.3, closed='right'),\n",
       "       Interval(1211.3, 1344.0, closed='right'),\n",
       "       Interval(1344.0, 1479.0, closed='right'),\n",
       "       Interval(1479.0, 1603.2, closed='right'),\n",
       "       Interval(1603.2, 1716.0, closed='right'),\n",
       "       Interval(1716.0, 1893.0, closed='right'),\n",
       "       Interval(1893.0, 2166.4, closed='right'),\n",
       "       Interval(2166.4, inf, closed='right')], dtype=object)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sort(np.ravel(test_t['GrLivArea'].unique()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "fengine",
   "language": "python",
   "name": "fengine"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
